package com.bl.student.dao.repository;

//import com.bl.mall.dao.model.LunboEntity;
import com.bl.student.dao.model.ApplyEntity;
import com.bl.student.dao.model.OrderEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by liangweikang on 18/12/30.
 */
public interface OrderRepository extends JpaRepository<OrderEntity, String> {

    Page<OrderEntity> findAllByOrderByCreateTimeDesc(Pageable pageable);

    @Query(value = "select * from goods_order where if(?1 !='',partyb_id=?1,1=1) and if(?2 !='',goods_id=?2,1=1)" +
            "and if(?3 !='',ordersn=?3,1=1) and if(?4 !='',express=?4,1=1) and if(?5 !='',status=?5,1=1) ORDER BY create_time DESC \n#pageable\n",
            countQuery ="select * from goods_order where if(?1 !='',partyb_id=?1,1=1) and if(?2 !='',goods_id=?2,1=1) and if(?3 !='',ordersn=?3,1=1) and if(?4 !='',express=?4,1=1) and if(?5 !='',status=?5,1=1)",
            nativeQuery = true)
    Page <OrderEntity>  findMultList(String partybId, String goodsId, String ordersn , String express, String status, Pageable pageable );


//    Page<OrderEntity> findByPartybIdOrderByCreateTimeDesc(String memberid, Pageable pageable);

    Page<OrderEntity> findByPartybIdAndStatusOrderByCreateTimeDesc(String partbId, String status, Pageable pageable);

//    Page<OrderEntity> findByOrdersnOrderByCreateTimeDesc(String ordersn, Pageable pageable);

//    Page<OrderEntity> findByPartybNameLikeOrderByCreateTimeDesc(String partybname, Pageable pageable);

//    Page<OrderEntity> findByPartybMobileOrderByCreateTimeDesc(String partybmobile, Pageable pageable);

//    Page<OrderEntity> findByClassidOrderByCreateTimeDesc(int classid, Pageable pageable);

//    List<OrderEntity> findByCreateTimeBetweenOrderByCreateTimeDesc(long startTime, long endTime);

//    List<OrderEntity> findByCreateTimeBetweenAndIsmoneyAndClassid(long startTime, long endTime, int ismoney, int classid);
}
